import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.preprocessing.text import Tokenizer

sentenses=[
    'I love my dog',
    'I love my cat',
    'You love my dog!',
    'Do you think my dog is amazing?'
]

tokenizer=Tokenizer(num_words=100)
tokenizer.fit_on_texts(sentenses)   # take in the data and encodes it
word_index=tokenizer.word_index     # key:word  index:the token of the word

sequences=tokenizer.texts_to_sequences(sentenses)

print(word_index)
print(sequences)

test_data=[
    'I really love my dog',
    'my dog loves my manatee'
]
test_seq=tokenizer.texts_to_sequences(test_data)
print(test_seq)